package ynu.edu.feign;

import org.springframework.stereotype.Component;
import ynu.edu.entities.BaseResponse;

import java.util.HashMap;
import java.util.Map;

/**
 * Food服务Feign客户端降级实现
 */
@Component
public class FoodFeignClientFallback implements FoodFeignClient {

    @Override
    public BaseResponse<Map<String, Object>> getFoodById(Integer foodId) {
        Map<String, Object> fallbackData = new HashMap<>();
        fallbackData.put("foodId", foodId);
        fallbackData.put("foodName", "暂无数据-" + foodId);
        fallbackData.put("foodPrice", 10.00);  // 设置一个默认价格，避免价格为0
        fallbackData.put("foodImg", "");
        fallbackData.put("foodExplain", "暂无描述");
        
        // 返回成功状态，而不是错误状态
        return BaseResponse.success(fallbackData);
    }
} 